package prototype.shallow;

import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;
import java.util.stream.Stream;

/**
 * @author Feng
 * @date 2019/3/11 22:45
 */
public class PrototypeTest {
    public static void main(String[] args) {
        ConcretePrototype concretePrototype = new ConcretePrototype();
        concretePrototype.setName("test");
        concretePrototype.setAge(20);

        List<String> list = (ArrayList)Stream.of("游泳，排球").collect(Collectors.toList());
        concretePrototype.setHobbies(list);
        System.out.println(concretePrototype);

        ConcretePrototype concretePrototype1 = concretePrototype.clone();
        System.out.println(concretePrototype.getHobbies());
        System.out.println(concretePrototype1.getHobbies());
        System.out.println(concretePrototype.getHobbies() == concretePrototype1.getHobbies());
        list.add("写代码");
        System.out.println(concretePrototype.getHobbies());
        System.out.println(concretePrototype1.getHobbies());
        System.out.println(concretePrototype.getHobbies() == concretePrototype1.getHobbies());
    }
}
